package similarite;
/**
 * 
 */
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.ListIterator;

import Jama.Matrix;


public class TestIndex {

	Main index;

	/**
	 * Joue le role de tests unitaires et d'integration
	 */
	public TestIndex(Main indexation) {              

		                this.index = indexation;
//		                indexation.normalizeAll();
				List<Image>lImage = indexation.saveAllImage();
		                Image [] im = new Image [lImage.size()];
		              // initialiser le tableau d'image 
		                int indice =0;
		                for(Image img : lImage){
		                	im[indice]= img;
		                	indice++;
		                }
		                
//		                int[][] matriceS =  indexation.matriceNN(im);
		                
//		               System.out.println(im[1].getImage().size());
		                //indexation.afficheMatrice(matriceD, 5, 5);
//		                System.out.println("========================");
		                //indexation.afficheMatrice(matriceD2, 5, 6);
//		                double[][] matriceS =  indexation.matriceNN(im);
		                
		               // System.out.println(matriceS[1][1]);
//		                indexation.afficheMatrice(matriceS, im.length, im.length);
//		                System.out.println("========================");
//		                double[][] matriceNorm =  indexation.normaliseMatriceNN(matriceS);
//		                indexation.afficheMatrice(matriceNorm, im.length, im.length);
		
		
		BufferedReader in = null;
		try {
			in = new BufferedReader(new FileReader("src/matrice_all_image.txt"));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String str = null;
		double[][]matriceP = new double[26][26];
		for (int i = 0; i< 26; i++) {
			try {
				str = in.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
//			System.out.println("STR : "+str);
			if (str != null) {
				String[] coords = str.split(" ");
				int j = 0;
				for (String s:coords) {
					if (!s.isEmpty()) {
						matriceP[i][j] = Float.parseFloat(s);
						j++;
					}
				}
			}
		}



		MDScaling mds = new MDScaling(new Matrix(matriceP));

	}

}